document.addEventListener('DOMContentLoaded', function() {  
    fetch('/student/addinfo') //后端API的URL  
    .then(response => response.json())  
    .then(data => {  
        const tbody = document.getElementById('history-tbody');  
        tbody.innerHTML = ''; // 清空现有的行  
        
        data.forEach(item => {  
            let row = `<tr>  
                <td>${item.course}</td>  
                <td>${item.status}</td>  
                <td>${item.score}</td>  
                <td>${item.date}</td>
                <td><a href="correct?id=${item.id}">错题记录</a></td>  
            </tr>`;  
            tbody.innerHTML += row;  
            console.log(item);
        });  
        
    })  
    .catch(error => console.error('Error fetching data:', error));  
});